package it.asvp.asvp_portal.data.entity.news;


import it.asvp.asvp_portal.data.entity.domain.File;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@SuppressWarnings("serial")
@Entity
@Table(name = "news_picture", catalog = "asvp_db", uniqueConstraints = @UniqueConstraint(columnNames = {
		"id_news", "id_picture" }))
public class NewsPicture implements java.io.Serializable {

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_news", nullable = false)
	private News news;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_picture", nullable = false)
	@Cascade({CascadeType.ALL})
	private File file;

	public NewsPicture() {
	}

	public NewsPicture(News news, File file) {
		this.news = news;
		this.file = file;
	}

	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	public News getNews() {
		return this.news;
	}

	public void setNews(News news) {
		this.news = news;
	}

	
	public File getFile() {
		return this.file;
	}

	public void setFile(File file) {
		this.file = file;
	}

}
